<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'access-index', //页面标示
    'pagename' => '节点列表', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array('content/jquery.smoothConfirm'),
    'head' => true, //加载头部文件
);

include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
  <section id="content">
    <!-- main padder --> 
    <section class="main padder">
        <div class="clearfix"> 
			<h4><i class="fa fa-table"></i><?php echo trim($Document['pagename'],'_');?></h4> 
        </div>
        <div class="row">
			<!-- table 11 -->
			<div class="col-lg-12"> 
            <!---->
          <div class="panel-body">
            <div class="row text-small">
              <div class="col-sm-8">
              <a class="btn btn-default" href="<?php echo U('access/add_access');?>">添加访问控制</a>
               <div data-resize="auto" class="select btn-group" style="margin-left:10px"> 
                  <button class="btn btn-white dropdown-toggle" data-toggle="dropdown" type="button"><span class="dropdown-label">帐号类型</span> <span class="caret"></span></button> 
                <ul class="dropdown-menu">
                <li data-value="0" <?php if(!$group_id){echo 'class="active"';}?>><a href="<?php echo U('access/list_access');?>">全部</a></li>
                <?php
                foreach($group as $key=>$val){
                ?>
                 <li data-value="<?php echo ($key+1);?>" <?php if($group_id==($key+1)){echo 'class="active"';}?>><a href="<?php echo U('access/list_access',array('group'=>($key+1)));?>"><?php echo $val;?></a></li>
                <?php
                }
                ?>
                </ul>
                </div>
              </div>
              <div class="col-sm-4">
                <form action="<?php echo U(ACTION_NAME.'/index');?>" method="get" name="form1" target="_self">
                  <div class="input-group">
                    <input type="text" name="q" class="input-sm form-control" placeholder="请输入关键字..." />
                    <input name="g" type="hidden" value="<?php echo GROUP_NAME;?>" />
                    <input name="c" type="hidden" value="<?php echo ACTION_NAME;?>" />
                    <input name="m" type="hidden" value="<?php echo MODEL_NAME;?>" />
                    <div class="input-group-btn">
                       <button data-toggle="dropdown" class="btn btn-white btn-sm dropdown-toggle">
                       <span class="dropdown-label">控制器</span><span class="caret"></span></button>
                       <ul class="dropdown-menu dropdown-select pull-right">
                       <li class="active"><a href="#"><input type="radio" checked="checked" name="st" value="c_action">控制器</a></li>
                        <li class=""><a href="#"><input type="radio" name="st" value="c_model">模块</a></li>
                        <li class=""><a href="#"><input type="radio" name="st" value="c_group">分组</a></li>
                       </ul> 
                      </div>
                      <span class="input-group-btn">
                      <button class="btn btn-sm btn-white" type="submit">搜索</button>
                      </span> </div>
                </form>
              </div>
            </div>
          </div>
          <!---->
				<section class="panel"> 
					<div class="table-responsive"> 
						<table class="table table-striped b-t text-small"> 
							<thead>
                              <tr>
                                <th align="center">ID</th>
                                <th align="center">用户组</th>
                                <th align="center">分组代码</th>
                                <th align="center">控制器代码</th>
                                <th align="center">模块代码</th>
                                <th align="center">操作</th>
                              </tr>
                            </thead>
                            <tbody>
                            <?php
                            if ($rs){
                                foreach($rs as $val){
                            ?>
                              <tr id="list_detail_<?php echo $val['id'];?>">
                                <td><?php echo $val['id'];?></td>
                                <td><?php echo $group[$val['group_id']];?></td>
                                <td><?php echo $val['n_group'];?></td>
                                <td><?php echo $val['n_action'];?></td>
                                <td><?php echo $val['n_model'];?></td>
                                <td>
                                <div class="btn-group"> 
                                    <button class="btn btn-white btn-xs dropdown-toggle" data-toggle="dropdown">操作<span class="caret"></span></button> 
                                    <ul class="dropdown-menu"> 
                                        <li><a href="javascript:;" rel="<?php echo $val['id'];?>" class="delete">删除</a></li>
                                    </ul> 
								</div>
                                </td>
                              </tr>
                              <?php
                                }
                            }else{
                              ?>
                             <tr>
                                <td colspan="8" align="center">暂无数据</td>
                              </tr>
                            <?php
                            }
                            ?>
                            </tbody> 
						</table> 
					</div> 
         			<footer class="panel-footer">
                    <div class="row">
                      <div class="col-sm-12 text-right text-center-sm">
                        <?php echo page($total,$p,'',20,'p');?></div>
                    </div>
                  </footer>
				</section> 
			</div> 
			<!--/ table 11 -->

        </div> 
    </section>
    <!--/ main padder -->  
  </section> 
  <!--/ content --> 
<!--主体 结束-->
<script>
$(function(){
	$('.delete').click(function(){
		var id=$(this).attr('rel');
	  $(this).smoothConfirm("确认删除该节点吗？", {
		  ok: function() {
			  Msg.loading();
			  $.post('<?php echo U('access/delete_access');?>',{"id":id},function(result){
				  Msg.hide();
				  if(result.status==1){
					  $("#list_detail_"+id).fadeOut();
				  }else{
					  Msg.error(result.info);
				  }
			  },'json');
		  },
		  //点击取消返回callback
		  cancel: function() {
			  return false;
		  }
	  });
	  $("body").click();//取消弹出层对对话框的遮蔽
	  return false;
	})	
})
</script>
<?php
include getTpl('footer', 'public');
?>